package com.czk.netty.netty.inboundandoutboundhandler.client;

import com.czk.netty.netty.inboundandoutboundhandler.server.MyByteToLongDecoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/1/20 22:41
 */
public class MyClientInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();
        // 加入出站handler对数据进行编码
        // 加入自定义handler 处理业务
        pipeline.addLast(new MyLongToByteEncoder());
        // 加入入栈handler接收服务器数据
        pipeline.addLast(new MyByteToLongDecoder());
        // 加入自己处理器
        pipeline.addLast(new MyClientHandler());

    }
}
